AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include('shared.lua')

ENT.Dropped = false;
ENT.typ = "weapon"
//models/Items/grenadeAmmo.mdl models/Weapons/W_missile_closed.mdl
//Sound local RocketSound = Sound( "Missile.Accelerate" )
function ENT:Initialize()


    self.Entity:SetModel("models/Weapons/W_missile_closed.mdl")
	self.Entity:SetAngles(Angle(0,0,0))
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS   )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	self.Entity:SetCollisionGroup( COLLISION_GROUP_PROJECTILE )
	self.Entity:GetPhysicsObject():EnableGravity( false )
	local phy = self.Entity:GetPhysicsObject()
	if phy:IsValid() then phy:Wake() end


	//self.Entity:EmitSound( "Missile.Accelerate" )
end

function ENT:PhysicsCollide(data, physobj)
 
 self:Explosion()
self.Entity:Remove()

end

function ENT:Think()



end

function ENT:OnTakeDamage( dmginfo )
end

function ENT:Explosion()
	
	local explo = ents.Create( "env_explosion" )
		explo:SetOwner( self.GrenadeOwner )
		explo:SetPos( self.Entity:GetPos() )
		explo:SetKeyValue( "iMagnitude", "100" )
		explo:Spawn()
		explo:Activate()
		explo:Fire( "Explode", "", 0 )
	
	local shake = ents.Create( "env_shake" )
		shake:SetOwner( self.GrenadeOwner )
		shake:SetPos( self.Entity:GetPos() )
		shake:SetKeyValue( "amplitude", "2000" )
		shake:SetKeyValue( "radius", "400" )
		shake:SetKeyValue( "duration", "2.5" )
		shake:SetKeyValue( "frequency", "255" )
		shake:SetKeyValue( "spawnflags", "4" )
		shake:Spawn()
		shake:Activate()
		shake:Fire( "StartShake", "", 0 )
	
	for k, v in pairs ( ents.FindInSphere( self.Entity:GetPos(), 250 ) ) do
		v:Fire( "EnableMotion", "", math.random( 0, 0.5 ) )
	end
	
end



function ENT:Touch( entity )

	self:Explosion()
	self.Entity:Remove()


end